{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "using NamedColors\n",
    "using Colors\n",
    "using ColorTypes\n",
    "using StatsBase"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "training_dict = load_xkcd();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "LoadError",
     "evalue": "UndefVarError: y_raw_1 not defined",
     "output_type": "error",
     "traceback": [
      "UndefVarError: y_raw_1 not defined",
      ""
     ]
    }
   ],
   "source": [
    "function encode_output(raw::Colorant)\n",
    "    #Encoding Angles: http://stats.stackexchange.com/a/218547/36769\n",
    "    hsv = convert(HSV, raw)\n",
    "    [(sind(hsv.h)+1)/2, (cosd(hsv.h)+1)/2, hsv.s, hsv.v]\n",
    "end\n",
    "\n",
    "function decode_output(out)\n",
    "    hue = rad2deg(atan2(2out[1]-1, 2out[2]-1))\n",
    "    sat = out[3]\n",
    "    val = out[4]\n",
    "    HSV(hue, sat, val)\n",
    "end\n",
    "\n",
    "y1 = encode_output(y_raw_1)\n",
    "@show y1\n",
    "decode_output(y1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "encode_input (generic function with 1 method)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function char2index(c::Char)::Int\n",
    "    if c ∈ 'a':'z'\n",
    "        c-'a'+1\n",
    "    elseif c==' '\n",
    "        'z'+1+1\n",
    "    elseif c=='/'\n",
    "        'z'+2+1\n",
    "    elseif c=='\\''\n",
    "        'z'+3+1\n",
    "    else\n",
    "        error(\"$c is out of range\")\n",
    "    end\n",
    "end\n",
    "function encode_input(name::AbstractString)\n",
    "    name_inds::Vector{Int} = char2index.(collect(name))\n",
    "    counts(name_inds, 26+3)./length(name)\n",
    "end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "using Learn\n",
    "import MNIST\n",
    "using MLDataUtils\n",
    "using StatsBase\n",
    "using StochasticOptimization.Iteration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "get_training (generic function with 1 method)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function get_training(training_dict)\n",
    "    colors = collect(values(training_dict))\n",
    "    y_train = hcat(encode_output.(colors)...)\n",
    "    \n",
    "    names = collect(keys(training_dict))\n",
    "    x_train = hcat(encode_input.(names)...)\n",
    "    x_train, y_train\n",
    "end\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(\n",
       "[0.0909091 0.0 … 0.166667 0.0588235; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0],\n",
       "\n",
       "Float32[0.994721 0.350743 … 0.230551 0.995183; 0.427534 0.977203 … 0.0788147 0.430766; 0.929032 0.892019 … 0.958333 0.595142; 0.607843 0.835294 … 0.376471 0.968627])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = get_training(training_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Method definition my_test_loss(Any, Any) in module Main at In[15]:2 overwritten at In[18]:2.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "StochasticOptimization.IterFunction(#10,1)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function my_test_loss(obj, testdata)\n",
    "    totloss = 0.0\n",
    "    totcorrect = 0\n",
    "    for (x,y) in each_obs(testdata)\n",
    "        totloss += transform!(obj,y,x)\n",
    "    end\n",
    "    totloss\n",
    "end\n",
    "\n",
    "\n",
    "tracer = IterFunction((obj, i) -> begin\n",
    "    if mod1(i,1000)==1000\n",
    "        totloss  = my_test_loss(obj, train, 500)\n",
    "        println(i, \" totloss:  \", totloss)\n",
    "    end\n",
    "end)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ObjectiveFunctions.RegularizedObjective{Transformations.Chain{Float64,Transformations.Params{SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},Tuple{},Tuple{}}},ObjectiveFunctions.LossTransform{Float64,LossFunctions.CrossentropyLoss},Penalties.ElasticNetPenalty{Float64}}(Chain{Float64}(\n",
       "   LayerNorm{29-->100, mu=0.0, sigma=1.0}\n",
       "   softplus{100}\n",
       "   LayerNorm{100-->64, mu=0.0, sigma=1.0}\n",
       "   softplus{64}\n",
       "   LayerNorm{64-->4, mu=0.0, sigma=1.0}\n",
       "   logistic{4}\n",
       ") ,ObjectiveFunctions.LossTransform{Float64,LossFunctions.CrossentropyLoss}(LossFunctions.CrossentropyLoss(),4,input(4,),target(4,),output(1,)),Penalties.ElasticNetPenalty{Float64}(1.0e-5,0.5))"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nin, nh, nout = size(train[1],1), [100,4^3], size(train[2],1)\n",
    "t = nnet(nin, nout, nh, :softplus, :logistic)\n",
    "obj = objective(t, ElasticNetPenalty(1e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "learner = make_learner(\n",
    "    GradientLearner(0.01, Adadelta()),\n",
    "    #tracer,\n",
    "    maxiter = 10_000\n",
    ")\n",
    "learn!(obj, learner, InfiniteBatches(train, size=5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Method definition get_colour(Any, Any) in module Main at In[22]:2 overwritten at In[26]:2.\n",
      "WARNING: Method definition display_colour(Any, Any) in module Main at In[22]:6 overwritten at In[26]:6.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "display_colour (generic function with 1 method)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function get_colour(obj, name)\n",
    "    transform!(obj,[0,0,0,0f0],encode_input(name))\n",
    "    decode_output( output_value(obj.transformation ))\n",
    "end\n",
    "function display_colour(obj,name)\n",
    "    display(name)\n",
    "    display(get_colour(obj, name))\n",
    "    display(\"-\"^16)\n",
    "end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"green\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#18F384\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(149.5905013062664,0.9030350246998327,0.9531060735371564)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"red\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#10F08A\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(152.6693847967789,0.9312659426634685,0.939891438794226)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"lightred\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#1CF6AF\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(160.4908860239486,0.8877468745290259,0.9665503261323041)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"dirtyred\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#10F3C5\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(167.7240114337142,0.93205962106644,0.9522107316947965)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"lightredishblue\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F81DF4\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-178.93767341229946,0.8812540645713083,0.9730531558291228)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"bluish red\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F511C4\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-167.05928898051855,0.9320330774966048,0.959796933544066)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"blue\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#FA2979\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-142.87334419783514,0.8350205031738338,0.980024122009809)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"light blue\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#FA2A4C\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-129.91372100211154,0.8331679125708057,0.9801785816655123)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"lightred\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#1CF6AF\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(160.4908860239486,0.8877468745290259,0.9665503261323041)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_colour(obj, \"green\")\n",
    "display_colour(obj, \"red\")\n",
    "display_colour(obj, \"lightred\")\n",
    "display_colour(obj, \"dirtyred\")\n",
    "display_colour(obj, \"lightredishblue\")\n",
    "display_colour(obj, \"bluish red\")\n",
    "display_colour(obj, \"blue\")\n",
    "display_colour(obj, \"light blue\")\n",
    "display_colour(obj, \"lightred\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"hot pink\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F71797\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-154.1502827204827,0.9057910245399418,0.9704785657562095)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"hot blue\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F5104E\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-136.26153761830454,0.9353091438089843,0.960514422904405)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"hot green\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#15F49C\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(156.41123878019403,0.9135414008159989,0.9552346328003533)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"dark blue\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F51030\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-128.31459244736848,0.9348773694898088,0.9606562498264314)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"light black\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#FA313E\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-123.82242038385401,0.8048813956128152,0.9817904034464621)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"black\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#FA286B\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-100.85578299693987,0.84143162596719,0.9787680562055688)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"dark black\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version\"1.0\" encoding=\"UTF-8\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"\n",
       "     width=\"25mm\" height=\"25mm\" viewBox=\"0 0 1 1\">\n",
       "     <rect width=\"1\" height=\"1\"\n",
       "           fill=\"#F61382\" stroke=\"none\"/>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "HSV{Float64}(-149.33561056796424,0.9238397905914646,0.9652956125865445)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"----------------\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display_colour(obj, \"hot pink\")\n",
    "display_colour(obj, \"hot blue\")\n",
    "display_colour(obj, \"hot green\")\n",
    "display_colour(obj, \"dark blue\")\n",
    "display_colour(obj, \"light black\")\n",
    "display_colour(obj, \"black\")\n",
    "display_colour(obj, \"dark black\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.5.0",
   "language": "julia",
   "name": "julia-0.5"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.5.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
